/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cassys.data.hibernate;

import cassys.domain.classManagement.Module;
import cassys.data.ModuleDAO;
import cassys.domain.classManagement.ClassGroup;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author User
 */
public class ModuleHibernateDAO extends GenericHibernateDAO<Module, Long>
        implements ModuleDAO {


    public ClassGroup getAllUnGroupParticipent(long moduleId){
        Criteria crit = getSession().createCriteria(ClassGroup.class, "classGroup");
        //crit.createAlias("classMembers", "p");
        crit.createAlias("module", "m");
        crit.add(Restrictions.eq("m.moduleId", moduleId));
        
        crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
        List<ClassGroup> resultList = crit.list();
        if(resultList != null && !resultList.isEmpty()){
            return resultList.get(0);
        }
        return null;

    }
}
